class GamblesController < ApplicationController
  layout 'template'
  # GET /gambles
  # GET /gambles.xml
  def index
    @gambles = Gamble.all

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @gambles }
    end
  end

  # GET /gambles/1
  # GET /gambles/1.xml
  def show
    @gamble = Gamble.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml => @gamble }
    end
  end

  # GET /gambles/new
  # GET /gambles/new.xml
  def new
    @gamble = Gamble.new

    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @gamble }
    end
  end

  # GET /gambles/1/edit
  def edit
    @gamble = Gamble.find(params[:id])
  end

  # POST /gambles
  # POST /gambles.xml
  def create
    @gamble = Gamble.new(params[:gamble])

    respond_to do |format|
      if @gamble.save
        flash[:notice] = 'Gamble was successfully created.'
        format.html { redirect_to(@gamble) }
        format.xml  { render :xml => @gamble, :status => :created, :location => @gamble }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @gamble.errors, :status => :unprocessable_entity }
      end
    end
  end

  # PUT /gambles/1
  # PUT /gambles/1.xml
  def update
    @gamble = Gamble.find(params[:id])

    respond_to do |format|
      if @gamble.update_attributes(params[:gamble])
        flash[:notice] = 'Gamble was successfully updated.'
        format.html { redirect_to(@gamble) }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.xml  { render :xml => @gamble.errors, :status => :unprocessable_entity }
      end
    end
  end

  # DELETE /gambles/1
  # DELETE /gambles/1.xml
  def destroy
    @gamble = Gamble.find(params[:id])
    @gamble.destroy

    respond_to do |format|
      format.html { redirect_to(gambles_url) }
      format.xml  { head :ok }
    end
  end
end
